<?php
App::uses('AppModel', 'Model');
/**
 * EventoConfig Model
 *
 */
class EventoConfig extends AppModel {

/**
 * Use table
 *
 * @var mixed False or table name
 */
	public $useTable = 'evento_config';
	
	public function value($key){
		$data = $this->findByKey($key);
		return $data['EventoConfig']['value'];
	}
	
	public function many_values($array){
		$data = $this->findAllByKey($array);
		$return = array();
		foreach($data as $item){
			$return[$item['EventoConfig']['key']] = $item['EventoConfig']['value'];
		}
		return $return;
	}
	
	public function saveValues($array){
		foreach($array as $key=>$item){
			$dados = $this->findByKey($key);
			$save[] = array('key'=>$key, 'value'=>$item, 'id'=>$dados['EventoConfig']['id']);
		}
		return $this->saveAll($save);
	}

}
